import React, { useEffect, useState } from 'react';
import { Button } from "antd";
function Theme() {
    const [theme,setTheme]=useState(()=>{
        const save=localStorage.getItem('theme')
        return save?save:'light'
    })
    useEffect(()=>{
        document.body.setAttribute('data-theme',theme)
        localStorage.setItem('theme',theme)
    },[theme])
    const qie=()=>{
        setTheme(theme==='light'?'dark':'light')
    }
    return (
        <div>
            <Button onClick={qie}>切</Button>
        </div>
    );
}

export default Theme;